package cn.com.sbell.vss.csg.vap;

import org.dom4j.Element;

import cn.com.sbell.vss.VssConstants;
import cn.com.sbell.vss.VssException;
import cn.com.sbell.vss.csg.vsclient.VsClient;
import cn.com.sbell.vss.csg.vsclient.util.BeanValidator;
import cn.com.sbell.vss.csg.vsclient.util.PropertiesHolder;
import cn.com.sbell.vss.csg.vap.bean.PPPoEPeriod;

public class SetVsPPPoEPeriod extends ProtectedVsCommander{

	@Override
	protected Element executeCommand(VsClient vsClient, PropertiesHolder holder, Element root) {
		// TODO Auto-generated method stub
		PPPoEPeriod validDays=(PPPoEPeriod) holder.populate(new PPPoEPeriod());
		BeanValidator.validateNotNull(
				validDays,
				new String[]{
						"pppoePeriod"
				}
		);
		
		if(!vsClient.SetVsPPPoEPeriod(validDays.getPppoePeriod().intValue()))
		{
			throw new VssException(VssConstants.CODE_SET_VS_PPPOE_PERIOD_FAILED);
		}
		return root;
	}

}
